package design_pattern.trigger.frame;

/**
 * @version 1.0.0
 * Created by cyd on 2022-08-29 17:07:18
 * @ClassName : design_pattern.trigger.frame.Product
 * @Description : 产品类，也就是事件源
 */
public class Product implements Cloneable {

    private String name;
    private boolean canChanged = false;

    public Product(ProductManager productManager, String name) {
        if (productManager.getCreateProduct()) {
            this.canChanged = true;
            this.name = name;
        }
    }

    public Object clone() throws CloneNotSupportedException {
        Product product = null;
        try {
            product = (Product) super.clone();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return product;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (canChanged) {
            this.name = name;
        }
    }

}
